<?php

use Illuminate\Http\Request;

/*Route::options('/{all}', function (Request $request) {
    $origin = $request->header('origin') ? $request->header('origin') : $request->header('referer');
    $allow_origin = [
        'http://localhost:9527','http://192.168.0.112:9527'
    ];
    if (in_array($origin, $allow_origin)) {
        header("Access-Control-Allow-Origin: $origin");
        header('Access-Control-Allow-Headers: Cache-Control, Transfer-Encoding, Connection, Origin, Content-Type, Token,Cookie, Accept, X-XSRF-TOKEN');
        header('Access-Control-Expose-Headers: *');
        header('Access-Control-Allow-Methods: *');
        header('Access-Control-Allow-Credentials: true');
    }
})->where(['all' => '([a-zA-Z0-9-_]|/)+']);*/
Route::namespace('Home')->group(function(){
    Route::get('/','Base@index');
    Route::post('/login','Auth@userLogin');
    Route::group(['prefix'=>'order','middleware' => 'tokenVerify'],function(){
        Route::post('/creadr','Order@addressAdd');//添加地址
        Route::post('/edtadr','Order@addressUpdate');//编辑地址
        Route::get('/adrshow','Order@addressList');//获取地址列表

        Route::post('/creord','Order@orderAdd');//商品订单添加
        Route::post('/crejord','Order@jifenOrderAdd');//积分商品订单添加
        Route::post('/credinord','Order@diniOrderSubmit');//餐桌订单提交

        Route::get('/getord','Order@prodOrderList');//获取地址列表
        Route::get('/getordetail','Order@prodOrderDetail');//获取订单详情
        Route::post('/edtadr','Order@addressEdit');//地址编辑
        Route::post('/deladr','Order@addressDelete');//地址删除
        Route::get('/jifendetail','Order@jifenOrderDetail');//获取积分商品订单详情
        Route::post('/delprodord','Order@prodOrderDelete');//商品订单删除
        Route::post('/consend','Order@prodOrderSendConfirm');//商品订单确认发货
        Route::get('/dinidetail','Order@DiniOrderDetail');//获取餐厅订单详情
        Route::get('/redetail','Order@rechargeDetail');//获取充值订单详情
        Route::get('/wddetail','Order@withDrawDetail');//获取提现订单详情

    });
    Route::group(['prefix'=>'auth','middleware' => 'tokenVerify'],function(){
        Route::get('/userinfo','Auth@userInfo');//获取用户信息
        Route::get('/ulevels','Auth@userLevels');//获取用户所有等级
        Route::post('/setinfo','Auth@userInfoSet');//设置用户资料
        Route::get('/uaddress','Auth@userAddresses');//获取用户所有地址
        Route::get('/spredinfo','Auth@spreadInfo');//获取用户推荐人信息
        Route::get('/stores','Auth@storeList');//获取用户存储记录
        Route::get('/spreds','Auth@spreadList');//获取用户推荐直属
        Route::post('/bdspred','Auth@bindSpread');//绑定推荐人
        Route::post('/passset','Auth@passWordSet');//设置登录密码
        Route::post('/payset','Auth@payPassSet');//设置交易密码
        Route::get('/consumes','Auth@consumption');//获取常消费记录

    });

    Route::group(['prefix'=>'pay','middleware' => 'tokenVerify'],function(){
        Route::post('/crepay','Pay@toTrans');//发起交易
        Route::post('/crejpay','Pay@toJefenTrans');//发起积分交易
        Route::post('/transed','Pay@transComplete');//交易完成
        Route::post('/jtransed','Pay@jifenTransComplete');//积分交易完成
        Route::get('/jtrans','Pay@jifenTransList');//积分交易记录列表
        Route::get('/exchange','Pay@jifenExchange');//积分兑换记录列表

    });

    Route::group(['prefix'=>'wallet','middleware' => 'tokenVerify'],function(){
        Route::get('/trans','wallet@transList');//交易记录列表
        Route::post('/recharge','wallet@recharge');//充值
        Route::get('/cagelist','Wallet@chargeList');//充值记录列表
        Route::post('/withdraw','Wallet@withdraw');//提现
        Route::get('/drawlist','Wallet@withDrawList');//提现记录列表
        Route::get('/banks','Wallet@bankList');//银行卡列表
        Route::post('/bindcard','Wallet@bindBankCard');//绑定银行卡
        Route::post('/edtbank','Wallet@bankCardEdit');//编辑银行卡
        Route::post('/delbank','Wallet@bankCardDelete');//解绑银行卡
        Route::get('/fanlist','Wallet@fanKuiList');//获取反馈钱包转移列表

    });
    Route::group(['prefix'=>'index'],function(){
        Route::get('/carousel','Index@carouselList');//轮播图接口
        Route::get('/products','Index@prodlList');//商品分页列表
        Route::get('/cates','Index@categories');//获取商品分类
        Route::get('/searches','Index@searchHistory');//获取搜索记录
        Route::get('/proddetail','Index@productDetail');//获取商品详情
        Route::get('/jfenprods','Index@jifenProdList');//获取积分商品分页记录
        Route::get('/jfproddetail','Index@jifenProdDetail');//获取积分商品详情
        Route::get('/cards','Index@bankCardList');//平台付款银行卡列表
    });

    Route::group(['prefix'=>'dini'],function(){
        Route::get('/dinings','Dini@dinings');//所有餐桌
        Route::get('/cprods','Dini@cateProducts');//分类下的商品
        Route::get('/userdini','Dini@userDinings');//获取用户预定餐桌
        Route::get('/tabstate','Dini@getTableStatus');//餐桌预定页面时间段判断
    });
});
